let  path = "/home/user/Documents/../Pictures"
var simplifyPath = function(path) {
    let arr = path.split('/') 
    
    
    for(let i=0;i<arr.length;i++){
        if(arr[i]==''||arr[i]=='.'){
            arr.splice(i,1)
            i--
        }else if(arr[i]=='..'){
            if(i-1>=0){
                arr.splice(i-1,2)
                i=i-2
            }else{
                arr.splice(i,1)
                i--
            }
        }
    }   
    

    let result = arr.join('/')
    result = '/'+result
    return result
    
};
simplifyPath(path)